{if="$user['level_name']=='officer'"}
<div style = "border:2px solid #ccc; padding:10px;margin-bottom:20px;">
<form action = "formula-update.php" method = "post">
	<input type = "hidden" name = "id" value = "{$assessment['id']}">
	<h2>สูตรคำนวน</h2>
	<br>
	1). <input type = "text" name = "formula_text" class = "w500" value = "{$assessment['formula_text']}"><br><br>
	2). แปลงค่าร้อยละที่คำนวนได้ในข้อที่ 1). เทียบกับคะแนนเต็ม 5<br><br>
	<hr><br>
	กำหนดให้เป็นคะแนนเต็ม 5 เท่ากับ
	<input type = "text" name = "percent" class = "w50" value ="{$assessment['percent']}">
	<select name = "unit">
		<option value = "1" {$check[0]}>หน่วย</option>
		<option value = "2" {$check[1]}>เปอร์เซ็น</option>
	</select>
	<br><br>
	<input type = "submit" value = "ตกลง">
</form>
</div>
{else}
<div style = "border:2px solid #ccc; padding:10px;margin-bottom:20px;">
<form action = "formula-cal.php" method = "post">
	<input type = "hidden" name = "id" value = "{$assessment['id']}">
	<h2>สูตรคำนวน</h2>
	<br>
	1). {$assessment['formula_text']}<br><br>
	<div class = "w300">
		<div class = "selectbox">
			<input type = "hidden" name = "common1" value = "{$common1['id']}">
			{if="$assessment['common1']==0"}
				<span>เลือก common data set<img src="images/arrow_down.png" class = "fr"></span>
			{else}
				<span>{$common1['name']} ({$common1['target']})<img src="images/arrow_down.png" class = "fr"></span>
			{/if}
			<ul>
				{loop="common"}
				<li val = "{$value.id}">{$value.name} ({$value.target})</li>
				{/loop}
			</ul>
			<div class = "clear"></div>
		</div>
		<div style = "float:right;font-size:16px;position:relative;left:200px;top:-5px;">{if="$assessment['unit']==2"}x 100{/if} = <input type = "text" name = "result1" class = "w80" value = "{$assessment['result']}" readonly="readonly"></div>
		<hr>
		<div class = "selectbox">
			<input type = "hidden" name = "common2" value = "{$common2['id']}">
			{if="$assessment['common2']==0"}
				<span>เลือก common data set<img src="images/arrow_down.png" class = "fr"></span>
			{else}
				<span>{$common2['name']} ({$common2['target']})<img src="images/arrow_down.png" class = "fr"></span>
			{/if}
			<ul>
				{loop="common"}
				<li val = "{$value.id}">{$value.name} ({$value.target})</li>
				{/loop}
			</ul>
			<div class = "clear"></div>
		</div>
	</div>
	<br><br>

	2). แปลงค่าร้อยละที่คำนวนได้ในข้อที่ 1). เทียบกับคะแนนเต็ม 5<br><br>
	<div class = "w200">
		<input type = "text" name = "result2" class = "w80" value = "{$assessment['result']}">
		<div style = "float:right;font-size:16px;position:relative;left:80px;top:-5px;z-index:1">x 5 = <input type = "text" name = "result" class = "w80" value = "{$assessment['result1']}" readonly="readonly"></div>
		<hr>
		<center>{$assessment['percent']}</center>
	</div>
	<br><br>


</div>

<script type="text/javascript">

$(function() {
	$(".selectbox span").click(function() {
		$(this).parent().find("ul").show();
	});

	$(".selectbox ul li").mouseover(function() {
		$(this).addClass("on");
	});

	$(".selectbox ul li").mouseout(function() {
		$(this).removeClass("on");
	});

	$(".selectbox ul li").click(function() {
		$(this).removeClass("on");
		var id = $(this).attr("val");
		$(this).parent().parent().find("input").val(id);
		$(this).parent().hide();
		$(this).parent().parent().find("span").html($(this).html()+'<img src="images/arrow_down.png" class = "fr">');
	});
});

</script>
{/if}